<?php
/**
 * PHP Framework Core HTTP Session class
 * This class represents an HTTP session object
 *
 * @author Andrew <andrew@vitche.com>
 * @author Frozen Rain <frozenrain@mail.ru>
 **/
class HttpSessionState {

    public function __get($name) {

        if (isset($_SESSION[$name])) {
            return $_SESSION[$name];
        }

        return null;
    }

    public function __set($name, $value) {
        $_SESSION[$name] = $value;
    }

    public static function currentInstance() {
        return new HttpSessionState();
    }

    public static function getFromRequest($name) {
        if (isset($_REQUEST[$name])) {
            HttpSessionState::currentInstance()->$name = $_REQUEST[$name];
            return $_REQUEST[$name];
        } else {
            return HttpSessionState::currentInstance()->$name;
        }
    }
}
?>